package com.kc.web.controller.business;

import com.kc.business.domain.BizScenicEnterForm;
import com.kc.business.domain.BizScenicFaceDevice;
import com.kc.business.service.IBizScenicFaceDeviceService;
import com.kc.common.annotation.Log;
import com.kc.common.core.controller.BaseController;
import com.kc.common.core.domain.AjaxResult;
import com.kc.common.core.page.TableDataInfo;
import com.kc.common.enums.BusinessType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName BizScenicFaceDeviceController
 * @Description TODO
 * @Author wangdongliang
 * @Date 2021/6/2 10:47
 */
@RestController
@RequestMapping("/business/scenicFaceDevice")
public class BizScenicFaceDeviceController extends BaseController {
    @Resource
    private IBizScenicFaceDeviceService scenicFaceDeviceService;

    /**
     * 获取列表
     * @param bizScenicFaceDevice
     * @return
     */
    @PreAuthorize("@ss.hasPermi('business:scenicFaceDevice:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizScenicFaceDevice bizScenicFaceDevice) {
        startPage();
        List<BizScenicFaceDevice> list = scenicFaceDeviceService.getList(bizScenicFaceDevice);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('business:scenicFaceDevice:add')")
    @Log(title = "硬件设备管理", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody @Validated BizScenicFaceDevice bizScenicFaceDevice){
        scenicFaceDeviceService.add(bizScenicFaceDevice);
        return AjaxResult.success();
    }

    @PreAuthorize("@ss.hasPermi('business:scenicFaceDevice:update')")
    @Log(title = "硬件设备管理", businessType = BusinessType.UPDATE)
    @PutMapping("/update")
    public AjaxResult update(@RequestBody @Validated BizScenicFaceDevice bizScenicFaceDevice){
        scenicFaceDeviceService.update(bizScenicFaceDevice);
        return AjaxResult.success();
    }

    @PreAuthorize("@ss.hasPermi('business:scenicFaceDevice:remove')")
    @Log(title = "硬件设备管理", businessType = BusinessType.DELETE)
    @PutMapping("/remove/{id}")
    public AjaxResult remove(@PathVariable("id") Integer id){
        BizScenicFaceDevice bizScenicFaceDevice = new BizScenicFaceDevice();
        bizScenicFaceDevice.setId(id);
        bizScenicFaceDevice.setIsDeleted(1);
        scenicFaceDeviceService.update(bizScenicFaceDevice);
        return AjaxResult.success();
    }
}
